<?php
$isReloadable = true;
require_once("../../pers/inc.config.php");
require_once(R2_FS_WEB_ROOT.'/app/_inc/inc.session.php');
require_once(R2_FS_WEB_ROOT.'/app/_inc/funct.html.php');

$aWhere = array();
if (reqVar('pagifilt')!='') {
	$aWhere[] = " (c.denominaz LIKE '%".addslashes(reqVar('pagifilt'))."%' ";
}
$sWhere = (count($aWhere)==0)? "":" WHERE ".implode(" AND ",$aWhere);

$sql_sel = "SELECT count(*) AS num_rec FROM cliente c " .$sWhere;
$objDB->query($sql_sel,'selRec');
$acRec = $objDB->fetch('selRec');
$numRec = $acRec['num_rec'];

$link = $_SERVER['PHP_SELF']."?".$sXSNQS;

$startOffset = 0;
$endOffset   = 0;
$sFiltro  = rint2GetFiltro($link);
$sPaginaz = rint2GetPaginaz($link, $numRec, $startOffset, $endOffset);

$sql_sel = " SELECT c.* FROM cliente c ".$sWhere
	." ORDER BY c.denominaz LIMIT "
	.$startOffset.",".($endOffset-$startOffset);
$objDB->query($sql_sel,'selRec');
//dbg_($sql_sel);

$cmdL = "";

if ($objSess->abilitaz['gescomm'] == 'W') {
	$cmdR = "&nbsp;&nbsp;&nbsp;";
	$cmdR .= "<a class=\"cmd1\" href=\"cliIns.php?$sXSNQS\">nuovo cliente</a>";
}
$cmdR .= cmdTorna(); 

$aMenuPag = array();
include("./_inc/inc.aMenuPag.php");
testaHtml('Lista Clienti', $msgPag, '30.10.10', $aMenuPag);

echo getHtmlForm();
echo getHtmlHidden('xsn',XSN);
echo getHtmlHidden('startoffset');
?>
<table class="cmd1" border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="left"><?=$cmdL?></td>
      <td class="cmd1" align="right"><?=$cmdR?></td>
   </tr>
   <tr>
      <td class="cmd1" align="left"><?=$sFiltro?></td>
      <td class="cmd1" align="right"><?=$sPaginaz?></td>
   </tr>
</table>
<table class="tab1" border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="tit1" colspan='9' align='center'>Lista Clienti</td>
   </tr>
   <tr>
      <td class="lab1" width='' align='center'>ID</td>
      <td class="lab1" width='' align='center'>Denominazione</td>
      <td class="lab1" width='' align='center'>Sospeso</td>
   </tr>
<? 
$clRF = 'txt2';
while ($acCli = $objDB->fetch('selRec')) { 
	$clRF = ($clRF=='txt1')?'txt2':'txt1';	
	$sStyle = '';
?>
   <tr>
      <td class="<?=$clRF?>" align="center" style='<?=$sStyle?>'>
	      <a href='cliView.php?id=<?=$acCli['id_cliente']."&$sXSNQS"?>' class="<?=$clRF?>" style='font-family:lucida console,courier;'>
	      	<?=$acCli['id_cliente'];?>
	      </a>
      </td>
      <td class="<?=$clRF?>" align="left" style='<?=$sStyle?>'>
	      <a href='cliView.php?id=<?=$acCli['id_cliente']."&$sXSNQS"?>' class="<?=$clRF?>">
	      	<?=$acCli['denominaz'];?>
	      </a>
      </td>
      <td class="<?=$clRF?>" align="center" style='<?=$sStyle?>'>
	      <?=$acCli['sospeso'];?>
      </td>
   </tr>
<? 
} 
?>
</table>
<table class="cmd1" border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="left">&nbsp;</td>
      <td class="cmd1" align="right"><?=$sPaginaz?></td>
   </tr>
   <tr>
      <td class="cmd1" align="left"><?=$cmdL?></td>
      <td class="cmd1" align="right"><?=$cmdR?></td>
   </tr>
</table>
<?
echo "</form>";

codaHtml();
exit();
